/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pkl53.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HP G42 (RILLA)
 */
@Entity
@Table(name = "kecamatan")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Kecamatan.findAll", query = "SELECT k FROM Kecamatan k"),
    @NamedQuery(name = "Kecamatan.findByB1r1", query = "SELECT k FROM Kecamatan k WHERE k.kecamatanPK.b1r1 = :b1r1"),
    @NamedQuery(name = "Kecamatan.findByB1r2", query = "SELECT k FROM Kecamatan k WHERE k.kecamatanPK.b1r2 = :b1r2"),
    @NamedQuery(name = "Kecamatan.findByNamaKecamatan", query = "SELECT k FROM Kecamatan k WHERE k.namaKecamatan = :namaKecamatan")})
public class Kecamatan implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected KecamatanPK kecamatanPK;
    @Column(name = "namaKecamatan")
    private String namaKecamatan;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kecamatan")
    private List<Kelurahan> kelurahanList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kecamatan1")
    private List<Kelurahan> kelurahanList1;

    public Kecamatan() {
    }

    public Kecamatan(KecamatanPK kecamatanPK) {
        this.kecamatanPK = kecamatanPK;
    }

    public Kecamatan(String b1r1, String b1r2) {
        this.kecamatanPK = new KecamatanPK(b1r1, b1r2);
    }

    public KecamatanPK getKecamatanPK() {
        return kecamatanPK;
    }

    public void setKecamatanPK(KecamatanPK kecamatanPK) {
        this.kecamatanPK = kecamatanPK;
    }

    public String getNamaKecamatan() {
        return namaKecamatan;
    }

    public void setNamaKecamatan(String namaKecamatan) {
        this.namaKecamatan = namaKecamatan;
    }

    @XmlTransient
    public List<Kelurahan> getKelurahanList() {
        return kelurahanList;
    }

    public void setKelurahanList(List<Kelurahan> kelurahanList) {
        this.kelurahanList = kelurahanList;
    }

    @XmlTransient
    public List<Kelurahan> getKelurahanList1() {
        return kelurahanList1;
    }

    public void setKelurahanList1(List<Kelurahan> kelurahanList1) {
        this.kelurahanList1 = kelurahanList1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (kecamatanPK != null ? kecamatanPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Kecamatan)) {
            return false;
        }
        Kecamatan other = (Kecamatan) object;
        if ((this.kecamatanPK == null && other.kecamatanPK != null) || (this.kecamatanPK != null && !this.kecamatanPK.equals(other.kecamatanPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pkl53.model.Kecamatan[ kecamatanPK=" + kecamatanPK + " ]";
    }
    
}
